import axios from "axios"

// 创建实例
const instance = axios.create({
    timeout: 15000,
    baseURL: "http://120.24.64.5:8088/mall-admin/"
});

// 请求拦截
instance.interceptors.request.use(config => {
    // 获取token值
    let token = localStorage.getItem("token");
    if(token){
        config.headers=config.headers || {};
        config.headers.Authorization=token
    }

    return config;
}), err => {
    return Promise.reject(err)
}

// 响应拦截
instance.interceptors.response.use(res => {
    return res.data;
}), err => {
    return Promise.reject(err);
}

export default instance;